package com.fc.commons;

import java.util.concurrent.atomic.AtomicLong;

public enum IDGenerator {
	INSTANCE;
	
	private static AtomicLong BaseID = new AtomicLong();
	
	// Shard ID
	private static int SID = 0;
	
	private static final long F_LEVEL = 100000L;
	/**
	 * 生成唯一id
	 * @return
	 */
	public long generateId(){
		return (System.currentTimeMillis() * F_LEVEL + SID * F_LEVEL) + BaseID.getAndIncrement();
	}

	public static int getSID() {
		return SID;
	}

	public static void setSID(int sID) {
		SID = sID;
	}
}
